package com.gitee.attendance;

import javax.servlet.MultipartConfigElement;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.util.unit.DataSize;

@ServletComponentScan
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class MyApplication {

	public static void main(String[] args) {
		SpringApplication.run(MyApplication.class, args);
	}
	    
    @Value("${multipart.maxFileSize:1024KB}")  
    private String maxFileSize;

    @Value("${multipart.maxRequestSize:1024KB}")  
    private String maxRequestSize;


    /**  
     * 文件上传配置  
     * @return  
     */  
    @Bean
    public MultipartConfigElement multipartConfigElement() {  
        MultipartConfigFactory factory = new MultipartConfigFactory();  
        //单个文件最大  
        
        factory.setMaxFileSize(DataSize.parse(maxFileSize)); //KB,MB  
        /// 设置总上传数据总大小  
        factory.setMaxRequestSize(DataSize.parse(maxRequestSize));  
        return factory.createMultipartConfig();  
    } 
}
